﻿using System;
using Urho.Desktop;
using Urho.Extensions.WinForms;

namespace E3Dcontrol
{
    /// <summary>
    /// E3MainControl 3D控件
    /// 使用方式：
    ///     实例化后放置到任意控件中。和一般winform控件一样使用
    ///     UrhoApplication属性为接口类，用于操作3D对象
    /// </summary>
    public class E3MainControl : System.Windows.Forms.UserControl
    {
        private UrhoSurface surface;

        public E3MainControl()
        {
            DesktopUrhoInitializer.AssetsDirectory = @"../../Assets";
            surface = new UrhoSurface
            {
                Dock = System.Windows.Forms.DockStyle.Fill
            };
            this.Controls.Add(surface);
        }

        protected async override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            UrhoApplication = await surface.Show<E3AppForUrho>(new Urho.ApplicationOptions("Data"));
        }

        public E3AppForUrho UrhoApplication { get; private set; }

    }
}
